<?php

/**
 * Subclass for representing a row from the 'tag' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Tag extends BaseTag
{
  public function getCultures()
  {
    $c = new Criteria();
    $c->add(TagI18nPeer::ID, $this->getId());
    $i18ns = TagI18nPeer::doSelect($c);
    
    $languages = array();
    foreach ($i18ns as $i18n)
    {
      $languages[] = $i18n->getCulture();
    }
    return $languages;    
  }
  
  public function countPublishedPosts()
  {
    $c = new Criteria();
    $c->add(PostPeer::PUBLISHED, '1');
    
    foreach ($this->getPostTags() as $post_tag)
    {
      $c->addOr($c->getNewCriterion(PostPeer::ID, $post_tag->getPostId()));
    }
    
    return PostPeer::doCount($c);
  }
}
